/*** 
 * @_______________#########_______________________ 
 * @______________############_____________________ 
 * @______________#############____________________ 
 * @_____________##__###########___________________ 
 * @____________###__######_#####__________________ 
 * @____________###_#######___####_________________ 
 * @___________###__##########_####________________ 
 * @__________####__###########_####_______________ 
 * @________#####___###########__#####_____________ 
 * @_______######___###_########___#####___________ 
 * @_______#####___###___########___######_________ 
 * @______######___###__###########___######_______ 
 * @_____######___####_##############__######______ 
 * @____#######__#####################_#######_____ 
 * @____#######__##############################____ 
 * @___#######__######_#################_#######___ 
 * @___#######__######_######_#########___######___ 
 * @___#######____##__######___######_____######___ 
 * @___#######________######____#####_____#####____ 
 * @____######________#####_____#####_____####_____ 
 * @_____#####________####______#####_____###______ 
 * @______#####______;###________###______#________ 
 * @________##_______####________####______________ 
 * @
 * @Author: ipk518 18163976442@163.com
 * @Date: 2024-09-20 15:46:54
 * @LastEditors: ipk518 121206530@qq.com
 * @LastEditTime: 2025-01-22 16:08:28
 * @FilePath: /etws-sxk2307/inc/para-ad.h
 * @Description: 
 * @************佛祖保佑************
 * @Copyright (c) 2024 by etws@quyujiang, All Rights Reserved. 
 */

#ifndef _AD_H_
#define _AD_H_



#pragma once
#include <stdio.h>
// #include <stdlib.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" 
{
#endif

#ifndef __cplusplus 
typedef enum _bool 
{
    false = 0,
    true,
}bool;
#define nullptr                                                                                                                             NULL
#endif

#define PS_BUILD_YEAR                       0x2024
#define PS_BUILD_MONTH                      0x08
#define PS_BUILD_DAY                        0x08

// 2307-x05ad
// NOTE: nested structure maximum layers is 2
// device voltage/current information.

// function declaration.
struct __attribute__ ((__packed__)) psVerisonInfo_ad
{
    uint16_t uVersionMajor; 
    uint16_t uVersionMinor;
    uint16_t uVersionPatch;
    uint16_t uYear;
    uint16_t uMonth;
    uint16_t uData;
};
struct __attribute__ ((__packed__)) plVerisonInfo_ad
{
        uint32_t Project_code;                 //项目代号
        uint32_t Components;                   //组件
        uint32_t Compilation_platform;         //编译平台
        uint32_t Compilation_Platform_UUID1;    //编译平台 UUID
        uint32_t Compilation_Platform_UUID2;    //编译平台 UUID
        uint32_t Compilation_Platform_UUID3;    //编译平台 UUID
        uint32_t Compilation_Platform_UUID4;    //编译平台 UUID
        uint32_t Compilation_date;             //编译日期
        uint32_t Compilation_time;             //编译时间
        uint32_t Project_version_number;       //工程版本号
        uint32_t Engineering_sub_version_number;       //工程子版本号
        uint32_t Vivado_version;                       //vivado版本
        uint32_t Vivado_sub_version;                   //vivado子版本
};

struct __attribute__ ((__packed__)) plStatus_ad
{
    uint8_t m_fiber_state_h;             //H极化光纤状态 0：掉线 1：在线
    uint8_t m_fiber_state_v;             //V极化光纤状态 0：掉线 1：在线  
    uint8_t m_fiber_offline_h;           //H极化光纤掉线计数
    uint8_t m_fiber_offline_v;           //V极化光纤掉线计数 

    uint8_t m_fiber_hard_err_h;          //H极化光纤硬件错误计数
    uint8_t m_fiber_hard_err_v;          //V极化光纤硬件错误计数
    uint8_t m_fiber_soft_err_h;          //H极化光纤软件错误计数
    uint8_t m_fiber_soft_err_v;          //V极化光纤软件错误计数

    uint8_t m_fiber_pll_err_h;          //H极化gt pll错误计数
    uint8_t m_fiber_pll_err_v;          //V极化gt pll错误计数

    uint32_t m_lvds_d0_state;            //LVDS训练状态d0
    uint32_t m_lvds_d1_state;            //LVDS训练状态d1
};

struct __attribute__ ((__packed__)) cvADParam_ad
{ 
    // uint8_t m_workMode;
        /* data */
    uint16_t m_mgt0v9Voltage;              //MGT0.9V电源电压/电流
    uint16_t m_mgt0v9Current;              //MGT0.9V电源电压/电流
    uint16_t m_mgt1v2Voltage;              //MGT1.2V电源电压/电流    
    uint16_t m_mgt1v2Current;              //MGT1.2V电源电压/电流
    uint16_t m_powerSupply3v3Voltage;      //3.3V电源电压/电流    
    uint16_t m_powerSupply3v3Current;      //3.3V电源电压/电流
    uint16_t m_powerSupply1v1Voltage;      //1.1V电源电压/电流
    uint16_t m_powerSupply1v1Current;      //1.1V电源电压/电流
    uint16_t m_powerSupply0v85Voltage;     //0.85V电源电压、电流
    uint16_t m_powerSupply0v85Current;     //0.85V电源电压、电流
    uint16_t m_fpgaAux1v8Voltage;          //1.8V电源电压/电流
    uint16_t m_fpgaAux1v8Current;          //1.8V电源电压/电流
	uint16_t m_ddr1v2Voltage;              //1.2V电源电源/电流
    uint16_t m_ddr1v2Current;              //1.2V电源电源/电流
    uint16_t m_powerSupply3v6Voltage;      //3.6V电源电压/电流
    uint16_t m_powerSupply3v6Current;      //3.6V电源电压/电流
    uint16_t m_powerSupply2v5Voltage;      //2.5V电源电压/电流
    uint16_t m_powerSupply2v5Current;      //2.5V电源电压/电流

};

struct __attribute__ ((__packed__)) subTemperature_ad
{
    float uPstemperature;               //PS片内温度
    float uPltemperature;               //PL片内温度
};
//组件状态
struct __attribute__ ((__packed__)) subAdStatus_ad
{
    uint16_t m_clockLock;//时钟锁定
};

struct __attribute__ ((__packed__)) hmc7044_ad
{
    uint8_t uIdlsb;                //HMC7044 24位产品ID   (MSB:0x7a MIB:0x79 LSB:0x78) 
    uint8_t uIdmid;            
    uint8_t uIdmsb;            
    uint8_t uClock0Lose;          //HMC7044 时钟0丢失                    (0x7c) 1：丢失 0：正常
    uint8_t uClock1Lose;          //HMC7044 时钟1丢失                    (0x7c) 1：丢失 0：正常
    uint8_t uClock2Lose;          //HMC7044 时钟2丢失                    (0x7c) 1：丢失 0：正常
    uint8_t uClock3Lose;          //HMC7044 时钟3丢失                    (0x7c) 1：丢失 0：正常
    uint8_t uPll1Pll2LockSt;    //HMC7044 PLL1和PLL2锁定检测           (0x7d) 1：锁定 0：失锁
    uint8_t uClockPhaseOut;      //HMC7044 时钟输出相位状态              (0x7d) 1：相位稳定 0：相位不稳定
    uint8_t uSysrefSyncSt;      //HMC7044 SYSREF同步状态               (0x7d) 1：不同步 0：同步
    uint8_t uRegisters7e;         //HMC7044 警报回读 查表 ：0x7e
    uint8_t uPll1ClkinValid;        //HMC7044 PLL1有效CLKIN0/CLKIN0输入    (0x82) 指示当前使用的CLKINx/CLKINx输入
    uint8_t uRegisters85;         //HMC7044 PLL1状态查询 查表：0x85
    uint8_t uRegisters8f;         //HMC7044 PLL2状态查询 查表：0x8f
};

struct __attribute__ ((__packed__)) sht3xData_r
{
    float uTemperature;            //sht35 温度
    float uHumidity;               //sht35 湿度
};

struct __attribute__ ((__packed__)) ad
{
    struct psVerisonInfo_ad psVerisonInfo;
    struct plVerisonInfo_ad plVerisonInfo;

    struct plStatus_ad plStatus;

    struct cvADParam_ad cvParam;
    struct subTemperature_ad tempParam;
    struct subAdStatus_ad subSt;

    struct hmc7044_ad hmc7044;
    // struct sht3xData_r sht3xData; //雷象心跳新增结构体，还未更新上报协议，先不用
};


#ifdef __cplusplus
}
#endif


#endif